/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.app.persistence;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;


/**
 *
 * @author esprit
 */
public class Recette {


     public static int idinc;
    private  int id;
    private String nom;
    private String categorie;
    private String ingredient;
    private int duree;
    private float note;
    private int favorie;
    private String remarques;
    private byte[] image;
    private float cout;
    private int nbr_personne;
    private String origine;

private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);

   /*public PropertyChangeSupport getChangeSupport() {
        return changeSupport;
    }*/

    public Recette(int id,String nom, String categorie, String ingredient, int duree, float note, int favorie, String remarques, byte[] image, float cout, int nbr_personne, String origine) {
       this.id=id;
       this.idinc=id+1;
        this.nom = nom;
        this.categorie = categorie;
        this.ingredient = ingredient;
        this.duree = duree;
        this.note = note;
        this.favorie = favorie;
        this.remarques = remarques;
        this.image = image;
        this.cout = cout;
        this.nbr_personne = nbr_personne;
        this.origine = origine;
    }

   public Recette()

   {

   }

    public float getCout() {
        return cout;
    }

    public int getFavorie() {
        return favorie;
    }

    public float getNote() {
        return note;
    }









    public String getCategorie() {
        return categorie;
    }



    public int getDuree() {
        return duree;
    }


    public byte[] getImage() {
        return image;
    }

    public String getIngredient() {
        return ingredient;
    }

    public int getNbr_personne() {
        return nbr_personne;
    }

    public String getNom() {
        return nom;
    }

    public String getOrigine() {
        return origine;
    }

    public String getRemarques() {
        return remarques;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        int oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public void setCout(float cout) {
        float oldcout = this.cout;
        this.cout = cout;
        changeSupport.firePropertyChange("cout", oldcout, cout);

    }

    public void setFavorie(int favorie) {
      float oldfav = this.favorie;
      this.favorie = favorie;
      changeSupport.firePropertyChange("favorie", oldfav, favorie);

    }

    public void setNote(float note) {
       float oldnote = this.note;

        this.note = note;
       changeSupport.firePropertyChange("note", oldnote, note);

    }


   /* public void setName(String name) {
        String oldName = this.name;
        this.name = name;
        changeSupport.firePropertyChange("name", oldName, name);
    }*/



    @Override
    public String toString() {
        return nom;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + this.id;
        return hash;
    }

    public void setCategorie(String categorie) {
        String oldcat = this.categorie;
        this.categorie = categorie;
        changeSupport.firePropertyChange("catgorie", oldcat, categorie);

    }

    public void setChangeSupport(PropertyChangeSupport changeSupport) {
        this.changeSupport = changeSupport;
    }

    public void setDuree(int duree) {
        int olddur = this.duree;
        this.duree = duree;
        changeSupport.firePropertyChange("duree", olddur, duree);

    }

    public void setImage(byte[] image) {
        byte[] oldimg = this.image;
        this.image = image;
        changeSupport.firePropertyChange("image", oldimg, image);
    }

    public void setIngredient(String ingredient) {
         String olding = this.ingredient;
        this.ingredient = ingredient;
        changeSupport.firePropertyChange("ingredients", olding, ingredient);
    }

    public void setNbr_personne(int nbr_personne) {
        int oldnbr = this.nbr_personne;
        this.nbr_personne = nbr_personne;
        changeSupport.firePropertyChange("nbr_personne", oldnbr, nbr_personne);

    }

    public void setNom(String nom) {
        String oldnom = this.nom;
        this.nom = nom;
        changeSupport.firePropertyChange("nom", oldnom, nom);

    }

    public void setOrigine(String origine) {
        String oldorig = this.origine;
        this.origine = origine;
       changeSupport.firePropertyChange("origine", oldorig, origine);

    }

    public void setRemarques(String remarques) {
        String oldrem = this.remarques;
        this.remarques = remarques;
        changeSupport.firePropertyChange("remarques", oldrem, remarques);

    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Recette other = (Recette) obj;
        if (this.id != other.id) {
            return false;
        }
        return true;
    }






    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }






}
